#include "Starfield.h"
#include "..\..\Constants.h"

void RespawnAffector::update(ds::Particles& particles,float elapsed) {
	for ( uint32 i = 0; i < particles.num();++i ) {
		ds::Particle* p = &particles[i];
		if ( !p->alive ) {
			p->alive = true;
			p->timer = rand() * 1.8f;
			int x = 10 + (int)(rand()*1004.0f);
			int y = 10 + (int)(rand()*748.0f);
			p->position = ds::Vec3(x,y,0);
			p->initialPosition = p->position;
			p->size = ds::Vec3(4,4,0);
			float angle = ds::math::getTargetAngle(ds::Vec2(512,384),ds::Vec2(p->position.x,p->position.y));
			ds::Vec2 v = ds::math::getRadialVelocity(RADTODEG(angle),16.0f);
			p->radialVelocity = 16.0f;
			p->velocity = ds::Vec3(v.x,v.y,0.0f);
			p->angle = 0.0f;
		}
	}	
}

